package com.blog.biz.impl;

import com.blog.biz.UserBiz;
import com.blog.dao.UserDao;
import com.blog.entity.User;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;
import javax.swing.plaf.ScrollPaneUI;
import java.io.Serializable;

/**
 * Created with IntelliJ IDEA.
 * Author:  Wu Yujie
 * Email:  coffee377@dingtalk.com
 * Time:  2017/02/16 00:33
 */
@Service
public class UserBizImpl implements UserBiz {
    @Resource
    private UserDao userDao;

    @Override
    public boolean existUser(String userName) {
        return userDao.existUser(userName);
    }

    @Override
    public User login(String userName, String password) {
        return userDao.login(userName, password);
    }

    @Override
    public void logout(HttpSession session) {

        System.out.println("查看用户信息1：" + session.getAttribute("USER").toString());
        session.removeAttribute("USER");
        if (null == session.getAttribute("USER")) {
            System.out.println("Session 中无用户信息");
        }
        session.invalidate();
        System.out.println("Session 失效");
    }

    @Override
    public Serializable register(User user) {
        return null;
    }
}
